import log from '../dxmodules/dxLogger.js'
import dxAlsaplay from '../dxmodules/dxAlsaplay.js'
import * as os from "os"


//handle id
const id = 'alsaplay1'

//Initialize the voice component
dxAlsaplay.init(id)
log.info('vg alsaplay start......,id =', id)

//The file for playing audio needs to exist in the corresponding directory of the device, as shown below.
dxAlsaplay.play("/app/code/resource/wav/0_eng.wav", id)

//Set the volume from 0 to 6.
let ret = dxAlsaplay.setVolume(6, id)
log.info("Adjust volume:", ret ? "success" : "fail")

//Get volume
let volume = dxAlsaplay.getVolume(id)
log.info("Get volume:", volume)

//Get supported volume range
let range = dxAlsaplay.getVolumeRange(id)
log.info("Get volume range:", range)

//Cancel initialization of handle id
let res = dxAlsaplay.deinit(id)
log.info("Cancel initialization:", res)

os.sleep(3000)
